package org.bluedream.core.config;

import org.apache.shiro.config.Ini;
import org.apache.shiro.config.Ini.Section;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.FactoryBean;

public class FilterChainDefinitionMap implements FactoryBean<Section> {
    private String defaultFilterChainDefinitions;
    private Section section;
    protected Logger logger = LoggerFactory.getLogger(this.getClass());

    public void setDefaultFilterChainDefinitions(String defaultFilterChainDefinitions){
        this.defaultFilterChainDefinitions = defaultFilterChainDefinitions;
    }

    @Override
    public Section getObject() throws BeansException {
        if (this.section == null){
            Ini a =new Ini();
            a.load(this.defaultFilterChainDefinitions);
            this.section = a.getSection("");
            this.section.putAll(a.getSection(""));
        }
        return this.section;
    }

    @Override
    public Class<?> getObjectType() {
        return this.getClass();
    }

    @Override
    public boolean isSingleton() {
        return false;
    }
}
